package com.blog.blogservice.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.blogservice.app.service.RoleUserService;
import com.blog.blogservice.domain.entity.RoleUser;
import com.blog.blogservice.infra.mapper.RoleUserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户角色关联表(RoleUser)应用服务
 *
 * @author guanglin.ma
 * @since 2024-03-10 22:54:11
 */
@Service
public class RoleUserServiceImpl extends ServiceImpl<RoleUserMapper, RoleUser> implements RoleUserService {

    @Override
    public List<RoleUser> selectRoleUser(RoleUser roleUser) {
        List<RoleUser> roleUserList = null;
        if (null != roleUser) {
            QueryWrapper queryWrapper = new QueryWrapper<>();
            queryWrapper.eq(roleUser.getUserId() != null, "user_id",
                    roleUser.getUserId());
            queryWrapper.eq(roleUser.getRoleId() != null, "role_id",
                    roleUser.getRoleId());
            roleUserList = baseMapper.selectList(queryWrapper);
        }

        return roleUserList;
    }
}

